﻿package utils.appli {
	
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import utils.ihm.ChevalIHM;
	import utils.appli.Couleur;
	public class Case extends Sprite {
		
		private var _couleurRGB:uint;
		private var _coordX:int;
		private var _coordY:int;
		private var _isOccup:Boolean;
		
		public function Case(caseX, caseY, uneCouleur:uint, carre:Boolean) {
			
			this._couleurRGB = uneCouleur;
			this._coordX = caseX;
			this._coordY = caseY;
			this.dessiner(caseX, caseY, carre);
			
		}
				
		private function dessiner(caseX, caseY, carre):void {
			this.graphics.lineStyle(1,this._couleurRGB);
			this.graphics.beginFill(this._couleurRGB);
			if(carre){
				this.graphics.drawRect(caseX-20, caseY-20, 40, 40);
			}else{
				this.graphics.drawCircle(caseX, caseY, 20);
			}
			_isOccup = false;
		}
			
		// TODO : OCCUPER AVEC UN CHEVAL DESSINE DE LA BONNE COULEUR
		/*public function occuper(joueur:String):void {
			this.graphics.beginFill(0x0000ff);
			this.graphics.drawCircle(this._coordX, this._coordY, 10);
			_isOccup = true;
		}
		
		public function inoccuper(joueur:String):void {
			this.graphics.beginFill(this._couleurRGB);
			this.graphics.drawCircle(this._coordX, this._coordY, 10);
			_isOccup = false;
		}
		*/
		
		public function occuper(aChevalIHM:ChevalIHM):void {
			this.addChild(aChevalIHM);
			_isOccup = true;
		}
		
		public function inoccuper():void {
			this.removeChildAt(0);
			_isOccup = false;
		}
		
		public function isOccupe(){
			return _isOccup;
		}
		
		public function get couleur():uint{
			return this._couleurRGB;
		}
		
	}
}